function loadjscssfile(filename, filetype) {
    if (filetype == "js") { //if filename is a external JavaScript file
        var fileref = document.createElement('script')
        fileref.setAttribute("type", "text/javascript")
        fileref.setAttribute("src", filename)
    }
    else if (filetype == "css") { //if filename is an external CSS file
        var fileref = document.createElement("link")
        fileref.setAttribute("rel", "stylesheet")
        fileref.setAttribute("type", "text/css")
        fileref.setAttribute("href", filename)
    }
    if (typeof fileref != "undefined") document.getElementsByTagName("head")[0].appendChild(fileref)
}

if(typeof jQuery =='undefined')
{
	loadjscssfile('http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js','js');
}
loadjscssfile('http://anti-ie6.googlecode.com/svn/trunk/css/jqModal.css','css');

var br1 = "Internet Explorer 7+";
var br2 = "Firefox 3+";
var br3 = "Safari 3+";
var br4 = "Opera 9.5+";
var br5 = "Chrome 2.0+";
var url1 = "http://www.microsoft.com/windows/Internet-explorer/default.aspx";
var url2 = "http://www.mozilla.com/firefox/";
var url3 = "http://www.apple.com/safari/download/";
var url4 = "http://www.opera.com/download/";
var url5 = "http://www.google.com/chrome";

function add_dialog()
{
	var $dialog = ['<div class="jqmWindow" id="ie6_warn">',
	'<h2>你的浏览器已经过时了！</h2>',
	'<p class="intro">为了获得最佳的浏览体验，建议你更新IE浏览器，或者选择其他更优秀的浏览器，下面是你可以考虑的浏览器列表</p>',
	'<ul class="clear">',
	'<li><a href="'+url1+'"><img src="http://anti-ie6.googlecode.com/svn/trunk/img/browser_ie.gif" /></a><p class="intro">'+br1+'</p></li>',
	'<li><a href="'+url2+'"><img src="http://anti-ie6.googlecode.com/svn/trunk/img/browser_firefox.gif" /></a><p class="intro">'+br2+'</p></li>',
	'<li><a href="'+url3+'"><img src="http://anti-ie6.googlecode.com/svn/trunk/img/browser_safari.gif" /></a><p class="intro">'+br3+'</p></li>',
	'<li><a href="'+url4+'"><img src="http://anti-ie6.googlecode.com/svn/trunk/img/browser_opera.gif" /></a><p class="intro">'+br4+'</p></li>',
	'<li><a href="'+url5+'"><img src="http://anti-ie6.googlecode.com/svn/trunk/img/browser_chrome.gif" /></a><p class="intro">'+br5+'</p></li>',
	'</ul>',
	'</div>'].join('');
	$('body').append($dialog);
}

function init()
{
	$(function(){
		add_dialog();
		$('#ie6_warn').jqm().jqmShow();
	});
}

function check_jq_loaded()
{
	if(typeof jQuery != 'undefined')
	{
		clearInterval(jq_intval);
		if(typeof $.jqm == 'undefined')
		{
			loadjscssfile('http://anti-ie6.googlecode.com/svn/trunk/script/jqModal.js','js');
			jqmodal_intval = setInterval('check_jqmodal_loaded()',1000);
		}
		else
		{
			init();
		}
	}
}

function check_jqmodal_loaded()
{
	if(typeof $.jqm != 'undefined')
	{
		init();
		clearInterval(jqmodal_intval);
	}
	
}

var jq_intval = setInterval('check_jq_loaded()',1000);
